package com.kw;




import com.kw.dao.IUserDao;
import com.kw.entity.User;
import com.kw.io.Resources;
import com.kw.sqlsession.SqlSession;
import com.kw.sqlsession.SqlSessionFactory;
import com.kw.sqlsession.SqlSessionFactoryBuilder;
import org.dom4j.DocumentException;

import java.beans.IntrospectionException;
import java.io.InputStream;
import java.lang.reflect.InvocationTargetException;
import java.sql.SQLException;
import java.util.List;

/**
 * Created by Medivh on 2020/5/7.
 * 愿我出走半生,归来仍是少年
 */
public class Test {

    public  static void main(String agrs[]) throws DocumentException, ClassNotFoundException, SQLException, NoSuchFieldException, IllegalAccessException, InstantiationException, IntrospectionException, InvocationTargetException {

        InputStream in = Resources.getResourcesAsStream("sqlMapConfig.xml");
        SqlSessionFactory sqlSessionFactory =new SqlSessionFactoryBuilder().build(in);
        SqlSession sqlSession = sqlSessionFactory.openSession();



//        User userSearch= new User();
//        userSearch.setId(1L);
//        userSearch.setUsername("chensk");
//        List<User> user = sqlSession.selectList("user.selectList",null);
//        System.out.print(user.size());



        IUserDao userDao = sqlSession.getMapper(IUserDao.class);
        System.out.print( userDao.findAll());


    }
}
